<?php
/**
 * Created by PhpStorm.
 * User: ZL
 * Date: 2016/4/19
 * Time: 10:54
 */
namespace Api\Controller;
use Think\Controller;
use ZL;
class BaseController extends Controller
{
    public function __construct()
    {
        parent::__construct();
        $sign = $_GET['sign'];
        $timestamp = $_GET['timestamp'];
        $_POST['timestamp'] = $timestamp;

        $appkey = C('APPKEY');
        $appSecret = C('APPSECRET');
        $smartSDK = new \ZL\SmartSDK($appkey, $appSecret);
        $r = $smartSDK->checkSign($sign,$_POST);
        if(!$r){
            $data=array();
            $data['status'] = 0;
            $data['sign'] = 'appSecret错误!';
            $this->ajaxReturn($data);
        }elseif((time()-$timestamp)>120){
            $data=array();
            $data['status'] = 0;
            $data['sign'] = 'appSecret已过期!';
            $this->ajaxReturn($data);
        }
    }
}
